import { BasicColumn, FormSchema } from '@/components/Table';
import { dateUtil } from '@/utils/dateUtil';

export const memberRechargeColumns: BasicColumn[] = [
  {
    title: '订单编号',
    dataIndex: 'sn',
    width: 100,
  },
  {
    title: '姓名',
    dataIndex: 'name',
    width: 50,
  },
  {
    title: '手机号',
    dataIndex: 'mobile',
    width: 50,
  },
  {
    title: '充值方式',
    dataIndex: 'payMethod',
    width: 50,
  },
  {
    title: '充值金额',
    dataIndex: 'amount',
    width: 70,
  },
  {
    title: '三方手续费',
    dataIndex: 'amount',
    width: 100,
    customRender: ({ record }) => {
      return record.amount * record.taxRatio;
    },
  },
  {
    title: '实际进账',
    dataIndex: 'reallyReceive',
    width: 100,
    customRender: ({ record }) => {
      return record.amount - record.amount * record.taxRatio;
    },
  },
  {
    title: '到账时间',
    dataIndex: 'payDate',
    width: 160,
    customRender: ({ text }) => {
      return dateUtil(text).format('YYYY-MM-DD HH:mm:ss');
    },
  },
  {
    title: '订单状态',
    dataIndex: 'status',
    width: 50,
    customRender: ({ text }) => {
      if (text == '0') {
        return '未支付';
      } else if (text == '1') {
        return '已支付';
      } else if (text == '2') {
        return '部分退款';
      } else if (text == '3') {
        return '全额退款';
      }
    },
  },
];
export const companyRechargeColumns: BasicColumn[] = [
  {
    title: '订单编号',
    dataIndex: 'sn',
    width: 100,
  },
  {
    title: '企业名称',
    dataIndex: 'companyName',
    width: 50,
  },
  {
    title: '充值金额',
    dataIndex: 'amount',
    width: 70,
  },
  {
    title: '充值方式',
    dataIndex: 'payMethodName',
    width: 50,
  },
  {
    title: '订单状态',
    dataIndex: 'status',
    width: 50,
    customRender: ({ text }) => {
      if (text == '0') {
        return '未支付';
      } else if (text == '1') {
        return '已支付';
      } else if (text == '2') {
        return '部分退款';
      } else if (text == '3') {
        return '全额退款';
      }
    },
  },
  {
    title: '当前余额',
    dataIndex: 'companyBalance',
    width: 70,
  },
  {
    title: '充值人员',
    dataIndex: 'adminName',
    width: 70,
  },
  {
    title: '充值时间',
    dataIndex: 'createDate',
    width: 160,
    customRender: ({ text }) => {
      return dateUtil(text).format('YYYY-MM-DD HH:mm:ss');
    },
  },

];
export const memberRechargeSearch: FormSchema[] = [
  {
    field: 'keyword',
    label: '姓名或手机号',
    component: 'Input',
    colProps: {
      span: 5,
    },
  },
  {
    field: 'payMethodId',
    label: '支付方式',
    component: 'Select',
    labelWidth: 90,
    componentProps: {
      options: [{ name: '微信', id: '2' }],
      fieldNames: {
        label: 'name',
        key: 'id',
        value: 'id',
      },
    },
    colProps: {
      span: 6,
    },
  },
  {
    field: 'startTime',
    label: '开始时间',
    component: 'DatePicker',
    componentProps: {
      format: 'YYYY-MM-DD',
      valueFormat: 'YYYY-MM-DD',
      style: { width: '100%' },
    },
    colProps: {
      span: 5,
    },
  },
  {
    field: 'endTime',
    label: '结束时间',
    component: 'DatePicker',
    componentProps: {
      format: 'YYYY-MM-DD',
      valueFormat: 'YYYY-MM-DD',
      style: { width: '100%' },
    },
    colProps: {
      span: 5,
    },
  },
];
export const companyRechargeSearch: FormSchema[] = [
  {
    component: 'ApiSelect',
    label: '企业',
    field: 'companyId',
    componentProps: {
      api: '/admin/main/companyList',
      valueField: 'id',
      labelField: 'name',
      showSearch: true,
      allowClear: true,
    }
  },
  {
    field: 'startTime',
    label: '开始时间',
    component: 'DatePicker',
    componentProps: {
      format: 'YYYY-MM-DD',
      valueFormat: 'YYYY-MM-DD',
      style: { width: '100%' },
    },
    colProps: {
      span: 5,
    },
  },
  {
    field: 'endTime',
    label: '结束时间',
    component: 'DatePicker',
    componentProps: {
      format: 'YYYY-MM-DD',
      valueFormat: 'YYYY-MM-DD',
      style: { width: '100%' },
    },
    colProps: {
      span: 5,
    },
  },
];
export const memberBalanceColumns: BasicColumn[] = [
  {
    title: '姓名',
    dataIndex: 'name',
    width: 100,
  },
  {
    title: '头像',
    dataIndex: 'headUrl',
    width: 50,
  },
  {
    title: '手机号',
    dataIndex: 'mobile',
    width: 70,
  },
  {
    title: '账户余额',
    dataIndex: 'balance',
    width: 50,
  },
  {
    title: '账户积分',
    dataIndex: 'point',
    width: 50,
  },
  {
    title: '累计充值',
    dataIndex: 'historyBalance',
    width: 50,
  },
  {
    title: '累计消费',
    dataIndex: 'consumeTotal',
    width: 50,
  },
  {
    title: '最后充电时间',
    dataIndex: 'lastChargeDate',
    width: 160,
    customRender: ({ text }) => {
      return dateUtil(text).format('YYYY-MM-DD HH:mm:ss');
    },
  },

];
export const memberBalanceSearch: FormSchema[] = [
  {
    field: 'keyword',
    label: '姓名或手机号',
    component: 'Input',
    colProps: {
      span: 5,
    },
  },
  {
    field: 'startTime',
    label: '开始时间',
    component: 'DatePicker',
    componentProps: {
      format: 'YYYY-MM-DD',
      valueFormat: 'YYYY-MM-DD',
      style: { width: '100%' },
    },
    colProps: {
      span: 5,
    },
  },
  {
    field: 'endTime',
    label: '结束时间',
    component: 'DatePicker',
    componentProps: {
      format: 'YYYY-MM-DD',
      valueFormat: 'YYYY-MM-DD',
      style: { width: '100%' },
    },
    colProps: {
      span: 5,
    },
  },
];
export const companyBalanceColumns: BasicColumn[] = [
  {
    title: '企业名称',
    dataIndex: 'name',
    width: 100,
  },
  {
    title: '账户余额',
    dataIndex: 'balance',
    width: 50,
  },
  {
    title: '账户积分',
    dataIndex: 'point',
    width: 50,
  },
  {
    title: '累计充值',
    dataIndex: 'historyBalance',
    width: 50,
  },
  {
    title: '累计消费',
    dataIndex: 'sumSpendMoney',
    width: 50,
  },

];
export const companyBalanceSearch: FormSchema[] = [
  {
    field: 'name',
    label: '企业名称',
    component: 'Input',
    colProps: {
      span: 5,
    },
  },
  {
    field: 'startDate',
    label: '开始时间',
    component: 'DatePicker',
    componentProps: {
      format: 'YYYY-MM-DD',
      valueFormat: 'YYYY-MM-DD',
      style: { width: '100%' },
    },
    colProps: {
      span: 5,
    },
  },
  {
    field: 'endDate',
    label: '结束时间',
    component: 'DatePicker',
    componentProps: {
      format: 'YYYY-MM-DD',
      valueFormat: 'YYYY-MM-DD',
      style: { width: '100%' },
    },
    colProps: {
      span: 5,
    },
  },
];